/*
 * Created by JFormDesigner on Sat Jul 16 08:27:52 EDT 2011
 */

package ca.etsmtl.log730.projet.view.client;

import java.awt.*;
import javax.swing.*;
import javax.swing.GroupLayout;
import ca.etsmtl.log730.projet.controller.client.*;
import org.jdesktop.beansbinding.*;
import org.jdesktop.beansbinding.AutoBinding.UpdateStrategy;
import org.jdesktop.swingx.*;

/**
 * @author Joe Labrosse
 */
public class JXConnectionDialog extends JDialog {
	public JXConnectionDialog(Frame owner) {
		super(owner);
		initComponents();
	}

	public JXConnectionDialog(Dialog owner) {
		super(owner);
		initComponents();
	}

	public ClientSetup getClientSetup() {
		return clientSetup;
	}

	private void initComponents() {
		// JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
		// Generated using JFormDesigner Evaluation license - Joe Labrosse
		xTextField1 = new JXTextField();
		xTextField2 = new JXTextField();
		xTextField3 = new JXLabel();
		xTextField4 = new JXLabel();
		btConnect = new JXButton();
		btCancel = new JXButton();
		clientSetup = new ClientSetup();

		//======== this ========
		setTitle("Connection...");
		Container contentPane = getContentPane();

		//---- xTextField3 ----
		xTextField3.setText("Hostname:");

		//---- xTextField4 ----
		xTextField4.setText("Port:");

		//---- btConnect ----
		btConnect.setText("Connect");

		//---- btCancel ----
		btCancel.setText("Cancel");

		GroupLayout contentPaneLayout = new GroupLayout(contentPane);
		contentPane.setLayout(contentPaneLayout);
		contentPaneLayout.setHorizontalGroup(
			contentPaneLayout.createParallelGroup()
				.addGroup(contentPaneLayout.createSequentialGroup()
					.addContainerGap()
					.addGroup(contentPaneLayout.createParallelGroup()
						.addGroup(contentPaneLayout.createSequentialGroup()
							.addGroup(contentPaneLayout.createParallelGroup()
								.addComponent(xTextField4, GroupLayout.PREFERRED_SIZE, 76, GroupLayout.PREFERRED_SIZE)
								.addComponent(xTextField3, GroupLayout.PREFERRED_SIZE, 76, GroupLayout.PREFERRED_SIZE))
							.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
							.addGroup(contentPaneLayout.createParallelGroup()
								.addComponent(xTextField1, GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
								.addComponent(xTextField2, GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)))
						.addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
							.addComponent(btCancel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
							.addComponent(btConnect, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
					.addContainerGap())
		);
		contentPaneLayout.setVerticalGroup(
			contentPaneLayout.createParallelGroup()
				.addGroup(contentPaneLayout.createSequentialGroup()
					.addContainerGap()
					.addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
						.addComponent(xTextField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(xTextField3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					.addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
						.addComponent(xTextField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(xTextField4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(18, 18, 18)
					.addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
						.addComponent(btConnect, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(btCancel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addContainerGap(17, Short.MAX_VALUE))
		);
		pack();
		setLocationRelativeTo(getOwner());

		//---- bindings ----
		bindingGroup = new BindingGroup();
		bindingGroup.addBinding(Bindings.createAutoBinding(UpdateStrategy.READ_WRITE,
			clientSetup, BeanProperty.create("hostname"),
			xTextField1, BeanProperty.create("text")));
		bindingGroup.addBinding(Bindings.createAutoBinding(UpdateStrategy.READ_WRITE,
			clientSetup, BeanProperty.create("port"),
			xTextField2, BeanProperty.create("text")));
		bindingGroup.bind();
		// JFormDesigner - End of component initialization  //GEN-END:initComponents
	}

	// JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
	// Generated using JFormDesigner Evaluation license - Joe Labrosse
	private JXTextField xTextField1;
	private JXTextField xTextField2;
	private JXLabel xTextField3;
	private JXLabel xTextField4;
	private JXButton btConnect;
	private JXButton btCancel;
	private ClientSetup clientSetup;
	private BindingGroup bindingGroup;
	// JFormDesigner - End of variables declaration  //GEN-END:variables
}
